<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>工作组管理</title>
		<%@include file="/WEB-INF/ibnms/common/jqgrid.jsp"%>
		<%@ include file="/WEB-INF/ibnms/common/formValidation.jsp"%>
		<jsp:include page="/WEB-INF/ibnms/common/configinclude.jsp"></jsp:include>
		<script language="javascript">
            function BtnSave_OnClick(theForm){
                var frm = theForm;
                if(frm.WORKGROUP_NAME.value==""){
                    alert("工作组名称不能为空！");
                    return;
                } 
                if(frm.ISMP_JSP_COMMAN.value=="add"){
                    var cComp = new String(parNode.getScript());
                    // if(parNode.child[0].text=="loading..."){
                    if(parNode.childCount==0||parNode.child[0].text=="loading..."){
                        var cscript=parNode.getScript()+"100";
                        parNode.delChild(0);
                    }else{
                        var cscript =parNode.child[parNode.childCount-1].getScript()+1;
                    }
                    var fold0 = parNode.addChild(parent.parent.leftFrame.Tree_LAST,frm.WORKGROUP_NAME.value,frm.WORKGROUP_NAME.value,frm.WORKGROUP_NAME.value);
                    fold0.setScript(cscript);
                    fold0.setLink("loadRoleModulesIndex.do?ROLE_ID="+cscript,"parent.rightFrame");
                    frm.ROLE_ID.value= cscript;
                }	
 
                if(frm.ISMP_JSP_COMMAN.value=="modify"){
                    var node=parent.parent.leftFrame.tree.getSelect();
                    var cscript= node.getScript();
                    node.setText(frm.WORKGROUP_NAME.value);
                }
                frm.ROLE_ID.value= cscript;
                if (frm.ROLE_ID.value==""){
                    alert("数据异常！");
                    return;
                }
                frm.action_type.value = "saveRole";
                frm.submit();	
                //alert(cscript);
            } 
        </script>
	</head>

	<body>
		<div class="form-wrapper">
	    	<div class="form-title">
	       		 <span class="ttcorner"></span>
	             <h3>
	                <span class="text">工作组配置</span>
	             </h3>
	        </div>
	        <div class="box-in">
	        	 <form id="editForm" action="<s:url action="saveWorkGroup"/>" method="post">
	        	 	<input type="hidden" name="theForm.SUPER_WG" value="${theForm.SUPER_WG}"></input>
					<input type="hidden" name="theForm.WORKGROUP_ID" value="${theForm.WORKGROUP_ID}"></input>
					<table id="table1" border="0" cellspacing="0" cellpadding="0" class="table-03">
						<tr>
				         	 <td class="monitor_bg1" height="13" align ="right" nowrap>
				         		工作组名称：
					         </td>
					         <td>
					         	<input type="text" name="theForm.WORKGROUP_NAME" id="WORKGROUP_NAME" class="validate[required,maxSize,50]" value='${theForm.WORKGROUP_NAME}' /><font color="red">*</font>
					         </td>
				   		</tr>
				   		<tr>
				         	 <td class="monitor_bg1" height="13" align ="right" nowrap>
				         		工作组描述：
					         </td>
					         <td>
					         	<textarea name="theForm.WORKGROUP_DESC" id="WORKGROUP_DESC" cols="80" class="validate[maxSize,128]" 
								rows="3">${theForm.WORKGROUP_DESC}</textarea>
							 </td>
				   		</tr>
				   		<tr>
				         	 <td class="monitor_bg1" height="13" align ="right" nowrap>
				         		生效：
					         </td>
					         <td>
					         	<select name="theForm.LOCKSTATE" id="LOCKSTATE" style="width:100px">
									<s:if test='%{theForm.LOCKSTATE==null||!theForm.LOCKSTATE.equals("1")}'>
										<option value="0" selected="selected">
											有效
										</option>
										<option value="1">
											无效
										</option>
									</s:if>
									<s:if test='%{theForm.LOCKSTATE.equals("1")}'>
										<option value="0">
											有效
										</option>
										<option value="1" selected>
											无效
										</option>
									</s:if>
								</select>
							 </td>
				   		</tr>
					</table>
					<div class="block03">
						<input type="button" class="btn-style02" id="btn-save" value="保存" />
						&nbsp;&nbsp;
						<input type="button" class="btn-style02" value="重置" onclick="resetForm()" />
						<input type="button" class="btn-style02" value="返回" onclick="back()" />
					</div>
	        	 </form>
	        </div>
        </div>
	</body>
	<script language="javascript">
		
		function back(){
			var pId = $("input[name='theForm.SUPER_WG']").val();
			window.location.href="<s:url action='loadWorkGroupUserList.do?theForm.SUPER_WG="+pId+"' namespace='/'/>";
		}
		function resetForm(){
			$('#editForm')[0].reset();
		}
		
        $("#btn-save").click(function() {
			$("#editForm").submit();
			parent.refreshNode();
		});
		
		$("#editForm").validationEngine().ajaxForm({
			type:"post",
			beforeSubmit:function() {
		        $("body").mask('正在保存,请稍后...');
			},
			success:function(data) {
				if (data == "true"){
					parent.refreshNode();
					var parentId = $("input[name='theForm.SUPER_WG']").val();
					window.location.href="<s:url action='loadWorkGroupUserList.do?theForm.SUPER_WG="+parentId+"' namespace='/'/>";
				} else {
					alert(data);
				}
			},
			error:function(xhr){
				$("body").unmask();
			   show_error(xhr);
			}
		});	
		
		
    </script>
</html>
